<?php
class CategoryModel extends Model {
	public function __construct() {
		parent::__construct("Category");
	}
	
	/**
	 * 获取所有栏目
	 */
	public function getAllCategoryWithCache() {
		$cache = Cache::getInstance(C('DATA_CACHE_TYPE'));
		$data = $cache->get('siteCategory');
		if(!empty($data)) {
			return $data;	
			
		} else {
			$data = $this->where('isshow=1')->order('listorder asc')->select();
			$cache->set('siteCategory', $data);
		}
		
		return $data;
	}
	public function delAllCategoryCahce() {
		$cache = Cache::getInstance(C('DATA_CACHE_TYPE'));
		
		return $cache->rm('siteCategory');  // 删除缓存	
	}
	
	public function getCategoryByCondition($where) {
		return $this->where($where)->order('listorder asc')->select();
	}
}